using System;
using Ease.EaseNode.Runtime.Param;

namespace Ease.EaseNode.Runtime
{
    [Serializable]
    public abstract partial class BaseEaseNodeData : IEaseNodeData
    {
        protected IEaseNodeAgent Agent { get; set; }

        public IEaseNodeAgent CreateAgent()
        {
            Agent = OnCreateAgent();
#if UNITY_EDITOR
            Agent.OnValueChangeEvent += OnValueChange;
            CreateState();
#endif
            return Agent;
        }

        protected abstract IEaseNodeAgent OnCreateAgent();

        protected virtual void OnAnyValueChange()
        {
#if UNITY_EDITOR
            OnValueChange(new DataChangeParam());
#endif
        }
    }
}